﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SendWPrdctShipLst.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.WModel.SendWPrdctShipLst" %>
<div class="pageContent ">
<form id="form1" method="post" action="WModel/SendWPrdctShipLst.aspx?ajaxmethod=search" onsubmit="return validateCallbackSendWPrdctShipLst(this);">
 <script type="text/javascript">

     //所有已选中的代理商
     var $selectagentname_SendWPrdctShipLst = "<%=AliasName %>";
     function SendWPrdctShipLstTreeCheck() {
         var json = arguments[0], result = "";
         if (json.checked) {
             $(json.items).each(function (i) {
                 // result += "<p>name:" + this.name + " value:" + this.value + " text: " + this.text + "</p>";
                 $selectagentname_SendWPrdctShipLst += this.name + ",";
             });
         }
         else {
             $(json.items).each(function (i) {
                 $selectagentname_SendWPrdctShipLst = $selectagentname_SendWPrdctShipLst.replace(this.name + ",", "");
             });
         }
         $("#SendWPrdctShipLst_ShowAgentName").val($selectagentname_SendWPrdctShipLst);
     }
    </script>   

   <div style="  border-color:#B8D0D6; border-style: solid;
    border-width: 0 0 1px;
    display: block;
    margin-bottom: 1px;
    overflow: auto;
    padding: 5px;background: url('/MachineSys/themes/default/images/pageHeader_bg.png') repeat-x scroll 0 0 #EBF0F5;" >
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <td>已下发生产任何的作业:</td>
                <td>
                    <select name="PID"  >
                        <%=GetProject() %>
                    </select>
                 </td>
                 <td>库位:</td>
                 <td>
                    <select name="U_KW">
                        <option value="" <%=U_KW==""?"selected":""%>>请选择</option>
                        <option value="1" <%=U_KW=="1"?"selected":""%>> 1</option>
                        <option value="2" <%=U_KW=="2"?"selected":""%>> 2</option>
                    </select>
                </td>
                 <td >
                    供应商:
                </td> 
                <td>
                     
                      <input type="hidden" id="SendWPrdctShipLst_ShowAgentName" name="AliasName" value="<%=AliasName %>" />
                      
                        <div class="agentlistdiv" >
                        <div class="panelBar">
                            <ul class="toolBar"  > 
                                <li style=" float:right;"><a href="#" class="closeselectagent delete"><span>确定选择</span></a></li>
                            </ul>
                        </div>
                        <div class="agentlisttreecon" >                                    
                            <ul class="tree treeCheck" oncheck="SendWPrdctShipLstTreeCheck">
                                <%=GetAgentList()%>
                            </ul>
                        </div>
                    </div>
                    <a href="#" class="openselectagent">选择供应商</a>
                </td>  
                <td>
                    物料:
                </td>
                <td>
                    <input type="text" name="ItemCode" class="autocomplete" value="<%=ItemCode %>"  autocompletehref="<%=AutoCompleteRequestUrl %>?ajaxmethod=getoitmlist&showtype=101" swidth="300"/>
                </td>                     
                <td >
                   <div class="subBar">
                        <ul>
                            <li>
                                <div class="buttonActive"><div class="buttonContent"><button type="submit">筛选</button></div></div>
                            </li>
                        </ul>
                    </div>
                </td> 
                            
            </tr>
           
        </table>
    </div>
    <div class="searchBar" style="text-align:right;">
        本次发料台数:<input type="text" id="SendWPrdctShipLst_NowSendPrdUnit" name="NowSendPrdUnit" style="width:90px!important;" class="inputFloat" value="<%=NowSendPrdUnit %>" />
    </div>
</div>
</form>
<form id="form2" runat="server" method="post" action="WModel/SendWPrdctShipLst.aspx?ajaxmethod=addtask" onsubmit="return validateCallback(this, navTabAjaxDone);">

<input type="hidden" name="PID" value="<%=PID %>" />
    <table class="list SendWPrdctShipLstTable" width="1000" layouth="94">
        <thead>
            <tr  >  
                <th width="100">供应商</th>               
                 <th width="100">
                    物料号
                </th>
                <th width="120">
                    物料名称
                </th>
                <th width="50">库位</th> 
                <th width="50">工位</th>                     
                <th width="70">
                    单台用量
                </th>
                <th width="70">生产台数</th>
                <th width="70">
                    需发料量
                </th> 
                <th width="70">
                    已发料量
                </th>
                <th width="70">未发料量</th> 
                <th width="70">本次发料量</th>
            </tr>
        </thead>
        <tbody>
    <asp:repeater id="rpMenu" runat="server">
        <ItemTemplate>
            <tr class="sendItemTr" >
				<td><%# Eval("AliasName")%></td>
				<td><%# Eval("ItemCode")%></td>
                <td><%# Eval("ItemName")%></td>
                <td><%# Eval("U_KW")%></td>
                <td><%# Eval("U_GW")%></td>
                <td><%#  Convert.ToDecimal(Eval("SingQty")).ToString("F2")%></td>
                <td><%#  Convert.ToDecimal(Eval("PrdUnit")).ToString("F0")%></td>
                <td><%#  Convert.ToDecimal(Eval("NeedQty")).ToString("F2")%></td>               
                <td><%#  Convert.ToDecimal(Eval("OutQty")).ToString("F2")%></td>
                 <td><%# (Convert.ToDecimal(Eval("NeedQty")) - Convert.ToDecimal(Eval("OutQty"))).ToString("F2")%></td>
                <td>
                    <input type="hidden" name="ID" value="<%# Eval("ID")%>" />
                    <input type="text" name="NowSendQty" style="width:70px!important;" class="inputFloat NowSendQty" value="0" minvalue="0" maxvalue="<%# (Convert.ToDecimal(Eval("NeedQty")) - Convert.ToDecimal(Eval("OutQty"))).ToString("F2")%>" PrdUnit="<%# Convert.ToDecimal(Eval("PrdUnit")).ToString("F2")%>" SingQty="<%# Convert.ToDecimal(Eval("SingQty")).ToString("F2")%>"/>
                </td>
			</tr>
        </ItemTemplate>
       
    </asp:repeater>
    </tbody>
         </table>
   <div class="formBar">
        <ul>  
            <li>
                <div class="buttonActive">
                    <a class="icon" href="WModel/ExportExcel/ExportSendWPrdctShipLst.aspx?PID=<%=PID %>&U_KW=<%=U_KW %>&AliasName=<%=Server.UrlEncode(AliasName) %>&NowSendPrdUnit=<%=NowSendPrdUnit %>&ItemCode=<%=ItemCode %>" target="_blank" title="确定要导出吗?">
                    <span>导出发料清单</span>
                    </a>
                </div>
            </li>         
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit">
                            确定发料</button>
                     </div>
                </div>
            </li>

        </ul>
    </div>
</div>
 
</form>
<script type="text/javascript">
    $(document).ready(function () {
        $("#SendWPrdctShipLst_NowSendPrdUnit").blur(function () {
            proccess();
        })
        function proccess() {
            var $NowSendPrdUnit = $("#SendWPrdctShipLst_NowSendPrdUnit").val();
            $(".SendWPrdctShipLstTable").find("input.NowSendQty").each(function () {
                var $objNowSendQty = $(this);
                var $PrdUnit = $objNowSendQty.attr("PrdUnit");
                var $minvalue = $objNowSendQty.attr("minvalue");
                var $maxvalue = $objNowSendQty.attr("maxvalue");
                var $SingQty = $objNowSendQty.attr("SingQty");

                var $jhvalue = $NowSendPrdUnit * $SingQty
                if ($jhvalue > $maxvalue)
                    $jhvalue = $maxvalue;
                $jhvalue = $jhvalue < 0 ? 0 : $jhvalue;
                $objNowSendQty.val($jhvalue);
            })
        }
        proccess();
        //单条处理
        $(".SendWPrdctShipLstTable").find("input.NowSendQty").blur(function () {
       
            var $objNowSendQty = $(this);
            var $PrdUnit = $objNowSendQty.attr("PrdUnit");
            var $minvalue = $objNowSendQty.attr("minvalue");
            var $maxvalue = $objNowSendQty.attr("maxvalue");
            var $SingQty = $objNowSendQty.attr("SingQty");

            var $jhvalue = $objNowSendQty.val();
            if ($jhvalue > $maxvalue)
                $jhvalue = $maxvalue;
            $jhvalue = $jhvalue < 0 ? 0 : $jhvalue;

            $objNowSendQty.val($jhvalue);
        })
    })
</script>
